package com.example.listener;

import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.utility.JavaModule;

//Agent增强结果回调
public class TransformListener implements AgentBuilder.Listener {

	@Override
	public void onDiscovery(String typeName, ClassLoader classLoader, JavaModule module, boolean loaded) {
	}

	@Override
	public void onTransformation(TypeDescription typeDescription, ClassLoader classLoader, JavaModule module,
			boolean loaded, DynamicType dynamicType) {
	}

	@Override
	public void onIgnored(TypeDescription typeDescription, ClassLoader classLoader, JavaModule module, boolean loaded) {
	}

	@Override
	public void onError(String typeName, ClassLoader classLoader, JavaModule module, boolean loaded,
			Throwable throwable) {
		System.out.printf("Agent throw error before running, typeName=%s, message=%s%n", typeName,
				throwable.getMessage());
		throwable.printStackTrace();
	}

	@Override
	public void onComplete(String typeName, ClassLoader classLoader, JavaModule module, boolean loaded) {
	}
}
